package com.ssy.lingxi.report.repository.settleaccount;

import com.ssy.lingxi.report.entity.settleaccount.PlatformSettlementDetailDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 平台代收账款结算明细
 * @author 伍将
 * @date 2020/12/14
 * @version 2.0.0
 */
public interface PlatformSettlementDetailRepository extends JpaRepository<PlatformSettlementDetailDO, Long>, JpaSpecificationExecutor<PlatformSettlementDetailDO> {

    /**
     * 删除积分结算明细
     * @author 伍将
     * @date 2020/12/14
     * @param settlementId:
     * @return:
     **/
    @Transactional
    void deleteAllBySettlementId(Long settlementId);

    /**
     * 根据条件按照订单时间倒序排列取一条数据
     * @author 伍将
     * @date 2020/12/14
     * @param memberId:
     * @param roleId:
     * @return:
     **/
    PlatformSettlementDetailDO findFirstByMemberIdAndRoleIdOrderByPayTimeDesc(Long memberId, Long roleId);

    /**
     * 根据结算id列表删除结算明细
     * @author 伍将
     * @date 2020/12/24
     * @param idList:
     * @return:
     **/
    @Transactional
    void deleteAllBySettlementIdIn(List<Long> idList);
}
